// JavaScript Document
function verify(responseXML) {
	var resp;
	var result = responseXML.getElementsByTagName("result");
	resp = result[0].firstChild.nodeValue;
	//alert(resp);
	
	if (resp == "okay") {
		//alert("okay");
		document.cookie = "username = " + document.getElementById("id_input").value;
		window.location="mainPage.html";
		
	} else {
		alert("用户名不存在或密码输入错误！");
		//window.location="register.html";
	}
}

function login() {
	if (document.getElementById("id_input").value === "") {
		alert("账户名不能为空！");
		return;
	}
	else if (document.getElementById("password_input").value === "") {
		alert("密码不能为空！");
		return;
	}
	var arguments = "<user>";
	arguments = addTag(arguments, "name", document.getElementById("id_input").value);
	arguments = addTag(arguments, "password", document.getElementById("password_input").value);
	arguments += "</user>";
	var url = "Login";
	sendXMLPost(url, arguments, verify);
}